import request from '@/utils/request'

export function generatorTable(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/system/generator/table`,
    method: 'post',
    data: query
  })
}

export function previewCode(tableId) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/system/generator/previewCode/${tableId}`,
    method: 'get'
  })
}

export function previewJsonSchema(sourceType, query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/public/jsonschema/pojo/preview/${sourceType}`,
    method: 'post',
    data: query
  })
}

export function loadTable(tableId) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/system/generator/loadTable/${tableId}`,
    method: 'get'
  })
}

export function loadColumn(tableId) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/system/generator/loadColumn/${tableId}`,
    method: 'post'
  })
}

export function generatorColumnSave(tableId, query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/system/generator/saveColumn/${tableId}`,
    method: 'post',
    data: query
  })
}

export function loadColumnRule(columnId) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/system/generator/loadRule/${columnId}`,
    method: 'get'
  })
}

export function saveColumnRule(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/system/generator/saveRule`,
    method: 'post',
    data: query
  })
}

export function generatorInit(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/system/generator/init`,
    method: 'post',
    data: query
  })
}
